package com.zengqingfa.demo.config;

import com.zengqingfa.demo.filter.MyFilter;
import com.zengqingfa.demo.listener.MyListener;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.EventListener;

/**
 * @author zengqingfa
 * @date 2019/11/22 14:44
 * @description
 * @email zengqingfa_java@163.com
 * <p>
 * 配置filter
 */
@Configuration
public class CustomerFilterConfig {

    /**
     * 注册过滤器
     *
     * @return
     */
     @Bean
    public FilterRegistrationBean myFilter() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new MyFilter());
        filterRegistrationBean.setName("myFilter");
        filterRegistrationBean.addUrlPatterns("/*");
        return filterRegistrationBean;
    }
}
